package com.asiainfo.kbisheet.services;
import java.util.List;

import org.springframework.stereotype.Service;

import com.asiainfo.kbisheet.util.BU;
import com.asiainfo.kbisheet.util.BUFactory;
import com.asiainfo.kbisheet.util.ExcelUtil;
import com.asiainfo.kbisheet.util.Setting;
import com.asiainfo.kbisheet.util.XMLFileUtil;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.CashboxService;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.AutoAuthQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.AutoAuthQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.CreateAppRequestQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.CreateAppRequestQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.CreateResRequestQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.CreateResRequestQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.LocalAuthQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.LocalAuthQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryAppOperJKStatusQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryAppOperJKStatusQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryJKStatusByIDQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryJKStatusByIDQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryResCmdJKStatusQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.QueryResCmdJKStatusQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.ReSendJKPassQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.ReSendJKPassQueryResult;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.RemoteAuthQueryParam;
import com.asiainfo.kbisheet.util.yunnan.aaaacashbox.vo.RemoteAuthQueryResult;
import com.asiainfo.kbisheet.vo.AllExportVO;
import com.asiainfo.kbisheet.vo.DimVO;
import com.asiainfo.kbisheet.vo.FromToDateVO;
import com.asiainfo.kbisheet.vo.KbsSheetVO;
import com.asiainfo.kbisheet.vo.LabelValueVO;
import com.asiainfo.kbisheet.vo.QueryVO;
import com.asiainfo.kbisheet.vo.SettingVO;
import com.asiainfo.kbisheet.vo.UserColumnHiddenVO;




/**
 * 针对Flex的服务
 * @author kyunra
 *
 */
@Service
public class FlexService {	
	private BU bu = BUFactory.createBU();
	private SettingVO settingVO = Setting.getSettingVO();
	
    /**
     * 全部导出服务
     * @param allExportVO
     * @param queryVO
     * @return
     */
	public boolean allExport(AllExportVO allExportVO,QueryVO queryVO){        
        return bu.allExport(allExportVO, queryVO);
    }
    
    public String createExcel(String xmlString){
		ExcelUtil excelUtil = new ExcelUtil();
		return excelUtil.createExcel(xmlString);
	}
    /**
     * 5.1	应用资源敏感操作金库状态查询接口
     * @param param
     * @return
     */
    public QueryAppOperJKStatusQueryResult aaaacashboxQueryAppOperJKStatus(QueryAppOperJKStatusQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	QueryAppOperJKStatusQueryResult result = cashboxService.queryAppOperJKStatus(param);
    	return result;    	
    }
    /**
     * 5.2	系统资源敏感指令金库状态查询接口
     * @param param
     * @return
     */
    public QueryResCmdJKStatusQueryResult aaaacashboxQueryResCmdJKStatus(QueryResCmdJKStatusQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	QueryResCmdJKStatusQueryResult result = cashboxService.queryResCmdJKStatus(param);
    	return result;    	
    }
    /**
     * 5.3	根据金库申请id查询金库状态接口
     * @param param
     * @return
     */
    public QueryJKStatusByIDQueryResult aaaacashboxQueryJKStatusByID(QueryJKStatusByIDQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	QueryJKStatusByIDQueryResult result = cashboxService.queryJKStatusByID(param);
    	return result;    	
    }
    /**
     * 6.1	应用资源敏感操作金库申请创建接口
     * @param param
     * @return
     */
    public CreateAppRequestQueryResult aaaacashboxCreateAppRequest(CreateAppRequestQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	CreateAppRequestQueryResult result = cashboxService.createAppRequest(param);
    	return result;    	
    }
    /**
     * 6.2	系统资源敏感指令金库申请创建接口
     * @param param
     * @return
     */
    public CreateResRequestQueryResult aaaacashboxCreateResRequest(CreateResRequestQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	CreateResRequestQueryResult result = cashboxService.createResRequest(param);
    	return result;    	
    }
    /**
     * 7.1	远程授权认证接口
     * @param param
     * @return
     */
    public RemoteAuthQueryResult aaaacashboxRemoteAuth(RemoteAuthQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	RemoteAuthQueryResult result = cashboxService.remoteAuth(param);
    	return result;    	
    }
    /**
     * 7.2	现场授权认证接口
     * @param param
     * @return
     */
    public LocalAuthQueryResult aaaacashboxLocalAuth(LocalAuthQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	LocalAuthQueryResult result = cashboxService.localAuth(param);
    	return result;    	
    }
    /**
     * 7.3	自动授权认证接口
     * @param param
     * @return
     */
    public AutoAuthQueryResult aaaacashboxAutoAuth(AutoAuthQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	AutoAuthQueryResult result = cashboxService.autoAuth(param);
    	return result;    	
    }
    /**
     * 8	金库口令重发接口
     * @param param
     * @return
     */
    public ReSendJKPassQueryResult aaaacashboxReSendJKPass(ReSendJKPassQueryParam param){
    	CashboxService cashboxService = new CashboxService();
    	ReSendJKPassQueryResult result = cashboxService.reSendJKPass(param);
    	return result;    	
    }
    /**
     * 对字符串进行解码
     * @param key
     * @param src
     * @return
     */
	public String decrypt(String key,String src){
        return bu.decrypt(key,src);
    }
    
    /**
     * 得到所有报表VO
     * @return
     */
	public List<KbsSheetVO> getAllKbsSheetVOList(){
        return bu.getAllKbsSheetVOList();
    }
	
    /**
	 * 得到数据库表列的XML信息
	 * @param dataBaseName
	 * @param tableName
	 * @return
	 */
	public String getColumnsXML(String dataBaseName,String tableName){
		return bu.getColumnsXML(dataBaseName,tableName);
	}
    
	public String getDataXML(QueryVO queryVO){
		return bu.getDataXML(queryVO);
	}
	
	public FromToDateVO getDimDate(DimVO dimVO){
		return bu.getDimDate(dimVO);
	}
	
	public List<LabelValueVO> getDimList(DimVO dimVO){
    	return bu.getDimList(dimVO);
    }
	
	/**
     * 得到系统设置项
     * @return
     */
	public SettingVO getSettingVO(){
    	return settingVO;
    }
	
	/**
	 * 根据报表ID加载KbsSheetVO对象
	 * @param sheetId
	 * @return
	 */
	public KbsSheetVO loadKbsSheetVO4Id(String sheetId){
		 return bu.loadKbsSheetVO4Id(sheetId);
	}
	
	public List<String> loadUserColumnSet(String userId,String sheetId){
		return bu.loadUserColumnSet(userId, sheetId);
	}
	
	/**
	 * 根据XML文件名加载文件内容
	 * @param xmlName
	 * @return
	 */
	public String loadXmlContent(String xmlName){
		return bu.loadXmlContent(xmlName);
	}
	
	/**
	 * 扫描配置模板目录下的XML文件
	 */
	public void scanXMLDir(){
		XMLFileUtil xmlFileUtil = new XMLFileUtil();
		xmlFileUtil.scanXMLDir();
	}
	
	public boolean saveUserColumnSets(UserColumnHiddenVO userColumnHiddenVO){
		return bu.saveUserColumnSets(userColumnHiddenVO);
	}
}
